package com.xuhai.blog.admin.controller;

import com.xuhai.blog.admin.service.CategoryService;
import com.xuhai.blog.admin.service.TimelineService;
import com.xuhai.blog.common.util.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author PangJunjie
 * @Date 2022/2/20/020
 */
@RestController
@RequestMapping("/admin")
public class EchartsController {
    @Autowired
    private TimelineService timelineService;
    @Autowired
    private CategoryService categoryService;

    @GetMapping("/echarts")
    public ResultJson echarts(){
        Map<String, Object> map = new HashMap<>();
        map.put("pieData",categoryService.getPieData());
        map.put("barData",timelineService.getTimeLine());
        return ResultJson.ok().data(map);
    }
}
